/*
Problem 3:
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143 ?
Answer: 6857
*/

#include <iostream>
#include <math.h>


using namespace std;

bool esPrimo(int);

int main(){

long long int num = 600851475143LL;
for(int i = static_cast<int>(sqrt(num));i >= 1;i--)
{
	if(num % i == 0)
	{ 
		if(esPrimo(i))
		{
		cout << i << endl;
		return 0;
		}
	}
}
return 0;
}



bool esPrimo(int i)
{
if (i % 2 == 0) return false;
for(int j = 3;j<= static_cast<int>(sqrt(i));j = j+2)
{
	if (i % j == 0) return false;
}

return true;


}






